<script type="text/javascript">
    var row = 1;
    var ggTable = document.getElementById('ggTable');
    function addGgRow() {
        row++;
        var newTr = ggTable.insertRow(-1);
        newTr.setAttribute('id','psk'+row);
        var newTd0 = newTr.insertCell(0);
        var newTd1 = newTr.insertCell(1);
        var newTd2 = newTr.insertCell(2);
        newTd0.innerHTML = '<td><input class="textInput" type="text" size="30" name="psk'+row+'"/></td>';
        newTd1.innerHTML = '<td><input class="textInput" type="text" size="30" name="psv'+row+'"/></td>';
        newTd2.innerHTML = '<td><a title="删除" target="ajaxTodo" class="btnDel" onclick="deleteGgRow(this)">删除</a></td>';
        document.getElementById('trLength').value = ggTable.rows.length-1;
    };
    function deleteGgRow(obj){
        if($("#ggTable tr").length > 2){
            row--;
            $(obj).parent().parent().remove();
            document.getElementById('trLength').value = ggTable.rows.length-1;
        }else{
            alertMsg.error('该行不能删除！');
        }
    };
    var tssxRow = 1;
    var tssxTable = document.getElementById('tssxTable');
    function addTssxRow(){
        tssxRow++;
        var newTr = tssxTable.insertRow(-1);
        newTr.setAttribute('id','ppk'+tssxRow);
        var newTd0 = newTr.insertCell(0);
        var newTd1 = newTr.insertCell(1);
        var newTd2 = newTr.insertCell(2);
        newTd0.innerHTML = '<td><input class="textInput" type="text" size="30" name="ppk'+tssxRow+'"/></td>';
        newTd1.innerHTML = '<td><input class="textInput" type="text" size="30" name="ppv'+tssxRow+'"/></td>';
        newTd2.innerHTML = '<td><a title="删除" target="ajaxTodo" class="btnDel" onclick="deleteTssxRow(this)">删除</a></td>';
        document.getElementById('spsTrLength').value = tssxTable.rows.length-1;
    };
    function deleteTssxRow(obj){
        if($("#tssxTable tr").length > 2){
            tssxRow--;
            $(obj).parent().parent().remove();
            document.getElementById('spsTrLength').value = tssxTable.rows.length-1;
        }else{
            alertMsg.error('该行不能删除!');
        }
    };
    function validate(){
        var inDate = document.getElementById('insdId').value;
        var outDate = document.getElementById('osdId').value;
        var start = new Date(inDate.replace(/\-/g,'/'));
        var end = new Date(outDate.replace(/\-/g,'/'));
        if(end<start){
            alertMsg.error('出库时间不能早于入库时间!');
            return false;
        }else{
            return true;
        }
    };
</script>
<div class="pageContent">
    <form id="myForm" method="post" action="addCp" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
        <div class="pageFormContent" layoutH="56">
            <input type="hidden" id="trLength" value="1" name="trleng"/>
            <input type="hidden" id="spsTrLength" value="1" name="spstrleng"/>
            <p>
                <label>SN：</label>
                <input name="psn" type="text" size="30"  class="digits required textInput" alt="请输入数字"/>
            </p>
            <p>
                <label>产品名称：</label>
                <input name="pName" class="required textInput" type="text" size="30" alt="请输入产品名称"/>
            </p>
            <p>
                <label>产品型号：</label>
                <input type="text" value="" class="required textInput" name="pType">
            </p>
            <p>
                <label>批  号：</label>
                <input name="pbn" class="digits" type="text" size="30" alt="请输入数字"/>
            </p>
            <p>
                <label>出厂日期：</label>
                <input type="text" name="pcd" class="date required textInput" size="30" /><a class="inputDateButton" href="javascript:;">选择</a>
            </p>
            <p>
                <label>部署地点：</label>
                <input type="text" size="30" name="pds"/>
            </p>
            <p>
                <label>生产入库时间：</label>
                <input type="text" id="insdId" name="pisd" class="date required textInput" size="30" /><a class="inputDateButton" href="javascript:;">选择</a>
            </p>
            <p>
                <label>入库质检人：</label>
                <input type="text" size="30" name="pisqp"/>
            </p>
            <p>
                <label>入库管理员：</label>
                <input type="text" size="30" name="piswa"/>
            </p>
            <p>
                <label>质保期：</label>
                <input type="text" size="30" name="pwar"/>
            </p>
            <p>
                <label>出库时间：</label>
                <input type="text" id="osdId" name="posd" class="date required textInput" size="30"/><a class="inputDateButton" href="javascript:;">选择</a>
            </p>
            <p>
                <label>出库管理员：</label>
                <input type="text" size="30" name="poswa"/>
            </p>
            <p>
                <label>提货性质：</label>
                <select name="pna" class="required combox">
                    <option value="">请选择</option>
                    <option value="出售" selected>出售</option>
                    <option value="出租">出租</option>
                </select>
            </p>
            <p>
                <label>提货人：</label>
                <input type="text" size="30" name="pbp"/>
            </p>
            <div class="divider"></div>
            <table id="ggTable" class="searchContent">
                <thead>
                <tr>
                    <th>规格名称（可选）</th>
                    <th>规格值（可选）</th>
                </tr>
                </thead>
                <tbody>
                <tr id="psk1">
                    <td>
                        <input type="text" size="30" name="psk1"/>
                    </td>
                    <td>
                        <input type="text" size="30" name="psv1"/>
                    </td>
                    <td>
                        <a title="添加行" class="btnAdd" onclick="addGgRow()">添加</a>
                    </td>
                </tr>
                </tbody>
            </table>
            <table id="tssxTable" class="searchContent">
                <thead>
                    <tr>
                        <th>特殊属性名（可选）</th>
                        <th>特殊属性值（可选）</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <input type="text" size="30" name="ppk1"/>
                        </td>
                        <td>
                            <input type="text" size="30" name="ppv1"/>
                        </td>
                        <td>
                            <a title="添加行" class="btnAdd" onclick="addTssxRow()">添加</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div class="formBar">
            <ul>
                <li><div class="buttonActive"><div class="buttonContent"><button type="submit" onclick="return validate();">保存</button></div></div></li>
                <li>
                    <div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
                </li>
            </ul>
        </div>
    </form>
</div>
